import 'package:flutter/material.dart';

//通过InheritedWidget实现数据共享
class ShareDataWidget extends InheritedWidget {

  const ShareDataWidget({Key? key, required Widget child, required this.data}) : super(key: key, child: child);

  final int data;

  static ShareDataWidget? of(BuildContext context) {
     return context.dependOnInheritedWidgetOfExactType<ShareDataWidget>();
  }

  @override
  bool updateShouldNotify(ShareDataWidget oldWidget) {
      return data != oldWidget.data;
  }

}